package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlOtherCommodityDetails;
import com.ruoyi.hualian.service.IHlOtherCommodityDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他型号详情Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/details")
public class HlOtherCommodityDetailsController extends BaseController
{
    @Autowired
    private IHlOtherCommodityDetailsService hlOtherCommodityDetailsService;

    /**
     * 查询其他型号详情列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlOtherCommodityDetails hlOtherCommodityDetails)
    {
        startPage();
        List<HlOtherCommodityDetails> list = hlOtherCommodityDetailsService.selectHlOtherCommodityDetailsList(hlOtherCommodityDetails);
        return getDataTable(list);
    }

    /**
     * 导出其他型号详情列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:export')")
    @Log(title = "其他型号详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlOtherCommodityDetails hlOtherCommodityDetails)
    {
        List<HlOtherCommodityDetails> list = hlOtherCommodityDetailsService.selectHlOtherCommodityDetailsList(hlOtherCommodityDetails);
        ExcelUtil<HlOtherCommodityDetails> util = new ExcelUtil<HlOtherCommodityDetails>(HlOtherCommodityDetails.class);
        util.exportExcel(response, list, "其他型号详情数据");
    }

    /**
     * 获取其他型号详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:query')")
    @GetMapping(value = "/{otherId}")
    public AjaxResult getInfo(@PathVariable("otherId") Long otherId)
    {
        return success(hlOtherCommodityDetailsService.selectHlOtherCommodityDetailsByOtherId(otherId));
    }

    /**
     * 新增其他型号详情
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:add')")
    @Log(title = "其他型号详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlOtherCommodityDetails hlOtherCommodityDetails)
    {
        return toAjax(hlOtherCommodityDetailsService.insertHlOtherCommodityDetails(hlOtherCommodityDetails));
    }

    /**
     * 修改其他型号详情
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:edit')")
    @Log(title = "其他型号详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlOtherCommodityDetails hlOtherCommodityDetails)
    {
        return toAjax(hlOtherCommodityDetailsService.updateHlOtherCommodityDetails(hlOtherCommodityDetails));
    }

    /**
     * 删除其他型号详情
     */
    @PreAuthorize("@ss.hasPermi('hualian:details:remove')")
    @Log(title = "其他型号详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherIds}")
    public AjaxResult remove(@PathVariable Long[] otherIds)
    {
        return toAjax(hlOtherCommodityDetailsService.deleteHlOtherCommodityDetailsByOtherIds(otherIds));
    }
}
